package com.study.mq;


import com.study.model.dto.request.SendSmsDto;
import com.study.util.api.SmsApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SmsConsumer {

    @Autowired
    private SmsApi smsApi;

    @RabbitListener(queuesToDeclare = @Queue("sms_queue"))
    public void sendSms(SendSmsDto dto) {
        smsApi.sendSms(dto.getPhone(), dto.getMessage());
    }

}
